import 'package:kepu/generated/json/base/json_convert_content.dart';
import 'package:kepu/model/region_entity.dart';

RegionEntity $RegionEntityFromJson(Map<String, dynamic> json) {
  final RegionEntity regionEntity = RegionEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    regionEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    regionEntity.msg = msg;
  }
  final List<RegionData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<RegionData>(e) as RegionData).toList();
  if (data != null) {
    regionEntity.data = data;
  }
  return regionEntity;
}

Map<String, dynamic> $RegionEntityToJson(RegionEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension RegionEntityExtension on RegionEntity {
  RegionEntity copyWith({
    int? code,
    String? msg,
    List<RegionData>? data,
  }) {
    return RegionEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

RegionData $RegionDataFromJson(Map<String, dynamic> json) {
  final RegionData regionData = RegionData();
  final int? regionId = jsonConvert.convert<int>(json['regionId']);
  if (regionId != null) {
    regionData.regionId = regionId;
  }
  final String? regionName = jsonConvert.convert<String>(json['regionName']);
  if (regionName != null) {
    regionData.regionName = regionName;
  }
  return regionData;
}

Map<String, dynamic> $RegionDataToJson(RegionData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['regionId'] = entity.regionId;
  data['regionName'] = entity.regionName;
  return data;
}

extension RegionDataExtension on RegionData {
  RegionData copyWith({
    int? regionId,
    String? regionName,
  }) {
    return RegionData()
      ..regionId = regionId ?? this.regionId
      ..regionName = regionName ?? this.regionName;
  }
}